
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}" scope="page"/>
<html>
<head>
    <title>Insert title here</title>
    <link rel="stylesheet" href="${ctx}/css/templatemo_style.css"/> <!-- 页面整体布局样式定义 -->
    <link rel="stylesheet" href="${ctx}/css/ddsmoothmenu.css" /> <!-- 菜单样式定义 -->
    <script type="text/javascript" src="${ctx}/js/jquery-1.4.3.min.js"></script>
    <script type="text/javascript">
        var ctx = "${pageContext.request.contextPath}";
        function showUserName(){
            var name = "${user.userName}";
            if(name != ""){
                $("#login").html(name);
                $("#exitP").show();
                $("#login").attr("href", ctx + "/user?flag=finduser&username=${user.userName}");
            }else{
                $("#login").html("登录");
                $("#exitP").hide();
                $("#login").attr("href", ctx + "/user?flag=lp");
            }
        }
        function a(price,productId,quantity,userId) {
            var quantity1 = quantity.value;
            var price1 = price;
            var sum =quantity1*price1;
            var zongji=0;
            alert(sum);
            $("#"+productId).text(sum+".0");
            $.post(
                "${ctx}/shopcart?flag=xg",
                {"productId":productId,"quantity":quantity1,"userId":userId},
                function(data){
                    alert(data);
                },
                "text"
            );
            $("td .mm").each(function (m) {
                zongji+=parseInt($(this).text());
            })
            alert(zongji);
            $("#heji").text(zongji+".0");
        }
    </script>
</head>

<body>
<div id="templatemo_body_wrapper">
    <div id="templatemo_wrapper">


        <!-- header -->
        <div id="templatemo_header">
            <div id="site_title"><h1><a href="${ctx}/home">穿美在线鞋城</a></h1></div>
            <div id="header_right">
                <p>
                    <a href="${ctx}/user?flag=lp" id="login">登录</a>&nbsp;
                    <span id="exitP" style="display: none"><a href="${ctx}/user?flag=logout" id="exit">注销</a></span>
                </p>
            </div>
            <div class="cleaner"></div>
        </div>
        <!-- END of templatemo_header -->


        <!-- menu -->
        <div id="templatemo_menubar">
            <div id="top_nav" class="ddsmoothmenu">
                <ul>
                    <li><a href="${ctx}/home">首页</a></li>
                    <li><a href="${ctx}/product">产品</a></li>
                    <li><a href="${ctx}/shopcart?&userId=${sessionScope.user.userId}" class="selected">我的购物车</a></li>
                    <li><a href="${ctx}/order">我的订单</a></li>
                </ul>
                <br style="clear: left" />
            </div> <!-- end of ddsmoothmenu -->
        </div><!-- END of templatemo_menubar -->


        <!-- main -->
        <div id="templatemo_main">
            <!-- 侧边栏 -->
            <div id="sidebar" class="float_l">
                <!-- sidebar 1 -->
                <div class="sidebar_box"><span class="bottom"></span>
                    <h3>品牌</h3>
                    <div class="content">
                        <ul class="sidebar_list">
                            <c:forEach items="${requestScope.categorys}" var="c">
                                <li><a href="${ctx}/product?categoryId=${c.categoryId}">${c.name}</a></li>
                            </c:forEach>
                        </ul>
                    </div>
                </div>
                <!-- sidebar 2 -->
                <div class="sidebar_box"><span class="bottom"></span>
                    <h3>热卖单品 </h3>
                    <div class="content">
                        <c:forEach items="${requestScope.hotSales}" var="hot">
                            <div class="bs_box">
                                <a href="${ctx}/product?productId=${hot.productId}&flag=d"><img src='${ctx}/${hot.imgpath}' alt="image" style="width:62px;height:72px"/></a>
                                <p><c:out value="${hot.feature}"></c:out></p>
                                <p class="price">￥${hot.price}</p>
                                <div class="cleaner"></div>
                            </div>
                        </c:forEach>
                    </div>
                </div>
            </div><!-- END of sidebar -->

            <!-- 内容展示区 -->
            <div id="content" class="float_r">
                <h3>购物车</h3>


                <table width="680px" cellspacing="0" cellpadding="5">
                    <tr bgcolor="#ddd">
                        <th width="220" align="left">图片 </th>
                        <th width="180" align="left">商品描述 </th>
                        <th width="100" align="center">数量 </th>
                        <th width="60" align="right">价格 </th>
                        <th width="60" align="right">小计 </th>
                        <th width="90"></th>
                    </tr>
                    <c:forEach items="${shoppingcart}" var="np">
                    <tr>
                        <td><a href="#"><img src="${ctx}/${np.getProduct().getImgpath()}" alt="image 1" /></a></td>
                        <td>${np.getProduct().getDescription()}</td>
                        <td><input type="text" class="quantity"  value="${np.getQuantity()}" onchange='a("${np.getProduct().getPrice()}","${np.getProductId()}",this,"${np.getUserId()}")' style="width:22px;height:14px;text-align:center;" /></td>
                        <td align="right" name="price" class="price1">${np.getProduct().getPrice()+".0"}</td>
                        <td align="right" ><span id="${np.getProductId()}" class="mm">${np.getSubtotal()}</span></td>
                        <td align="center">
                            <a href="${ctx}/shopcart?flag=sc&productId=${np.getProductId()}&cartId=${np.getShoppingCarId()}&userId=${np.getUserId()}"><img src="${ctx}/images/remove_x.gif" alt="remove" /><br />移除</a>
                        </td>
                    </tr>
                    </c:forEach>
                    <tr>
                        <!--td colspan="3" align="right"  height="30px"><span id="update">如果你已修改了商品，请单击 <a href="${ctx}/shopcart?flag=gx&userId="><strong>更新</strong></a></span>&nbsp;&nbsp;</td-->
                        <td align="right" style="background:#ddd; font-weight:bold"> 合计 </td>
                        <td align="right" style="background:#ddd; font-weight:bold"id="heji"> ${zong} </td>
                        <td style="background:#ddd; font-weight:bold"> </td>
                    </tr>
                </table>

                <div style="float:right; width: 215px; margin-top: 20px;">
                    <p><a href="${ctx}/shopcart?flag=an&zong=${zong}&userId=${sessionScope.user.userId}">结算</a></p>
                    <p><a href="${ctx}/home">继续购物</a></p>
                </div>



            </div>

            <div class="cleaner"></div>
        </div><!-- END of templatemo_main -->


        <!-- footer -->
        <div id="templatemo_footer">
            <p>
                <a href="${ctx}/home">首页</a> | <a href="${ctx}/product">产品</a> | <a href="${ctx}/shopcart">我的购物车</a> | <a href="${ctx}/order">我的订单</a>
            </p>
            版权所有 (c) 2018 <a href="javascript:void(0);">金桥软件</a>
        </div><!-- END of templatemo_footer -->


    </div><!-- END of templatemo_wrapper -->
</div><!-- END of templatemo_body_wrapper -->
<script type="text/javascript">
    $(function(){
        showUserName();
    });
</script>
</body>
</html>
